package com.ruoyi.bizsys.service.impl;

import java.math.BigDecimal;
import java.util.List;
import java.util.Arrays;

import com.ruoyi.bizsys.domain.LoanIou;
import com.ruoyi.bizsys.domain.ReduceFee;
import com.ruoyi.bizsys.mapper.ReduceFeeMapper;
import com.ruoyi.bizsys.service.IReduceFeeService;
import com.ruoyi.bizsys.utils.BizConstants;
import com.ruoyi.bizsys.vo.CollectionReduceOrderVo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bizsys.mapper.CollectionReduceOrderMapper;
import com.ruoyi.bizsys.domain.CollectionReduceOrder;
import com.ruoyi.bizsys.service.ICollectionReduceOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.transaction.annotation.Transactional;


/**
 * 催收减免订单Service业务层处理
 *
 * @author african-loan
 * @date 2022-08-15
 */
@Slf4j
@Service
public class CollectionReduceOrderServiceImpl extends ServiceImpl<CollectionReduceOrderMapper, CollectionReduceOrder> implements ICollectionReduceOrderService {


    @Autowired
    ReduceFeeMapper reduceFeeMapper;
    /**
     * 查询催收减免订单
     *
     * @param id 催收减免订单ID
     * @return 催收减免订单
     */
    @Override
    public CollectionReduceOrder selectCollectionReduceOrderById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询催收减免订单列表
     *
     * @param collectionReduceOrder 催收减免订单
     * @return 催收减免订单
     */
    @Override
    public List<CollectionReduceOrder> selectCollectionReduceOrderList(CollectionReduceOrder collectionReduceOrder) {
        return this.list(new QueryWrapper<>(collectionReduceOrder).last("order by id desc"));
    }

    /**
     * 新增催收减免订单
     *
     * @param collectionReduceOrder 催收减免订单
     * @return 结果
     */
    @Override
    public int insertCollectionReduceOrder(CollectionReduceOrder collectionReduceOrder) {
        collectionReduceOrder.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insert(collectionReduceOrder);
    }

    /**
     * 修改催收减免订单
     *
     * @param collectionReduceOrder 催收减免订单
     * @return 结果
     */
    @Override
    public int updateCollectionReduceOrder(CollectionReduceOrder collectionReduceOrder) {
        collectionReduceOrder.setUpdateTime(DateUtils.getNowDate());
        return baseMapper.updateById(collectionReduceOrder);
    }

    /**
     * 批量删除催收减免订单
     *
     * @param ids 需要删除的催收减免订单ID
     * @return 结果
     */
    @Override
    public int deleteCollectionReduceOrderByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除催收减免订单信息
     *
     * @param id 催收减免订单ID
     * @return 结果
     */
    @Override
    public int deleteCollectionReduceOrderById(Long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public List<CollectionReduceOrderVo> selectCollectionReduceOrderVoList(CollectionReduceOrder collectionReduceOrder) {
        return baseMapper.selectCollectionReduceOrderVoList(collectionReduceOrder);
    }

    @Override
    public CollectionReduceOrder selectCollectionReduceOrderByLoanNo(String loanSerialNo) {
        return baseMapper.selectCollectionReduceOrderByLoanNo(loanSerialNo);
    }

    @Override
    public CollectionReduceOrder selectOnAppleyingByLoanNo(String loanSerialNo) {
        return baseMapper.selectOnAppleyingByLoanNo(loanSerialNo);
    }

    @Override
    public CollectionReduceOrder selectNotUseByLoanNo(String loanSerialNo) {
        return baseMapper.selectNotUseByLoanNo(loanSerialNo);
    }
}